package by.bsu.wp.latextool.converter;

import java.util.Set;

import org.jgrapht.graph.DefaultEdge;


public class LatexBuilder {

	private StringBuilder builder;
	
	public LatexBuilder() {
		this.builder = new StringBuilder();
	}

	public LatexBuilder appendBeginDocumentExt() {
		this.builder.append("\\documentclass{article}");
		this.builder.append("\\usepackage{amssymb,amsmath}");
		this.builder.append("\\usepackage[english,russian]{babel}");
		this.builder.append("\\begin{document}");
		this.builder.append("\\begin{center}");
		this.builder.append("\n");
		return this;
	}
	
	public LatexBuilder appendEndDocumentExt() {
		this.builder.append("\n");
		this.builder.append("\\end{center}");
		this.builder.append("\\end{document}");
		return this;
	}
	
	public LatexBuilder appendFormulaMarker() {
		this.builder.append("$");
		return this;
	}
	
	public LatexBuilder appendFormulaItem(String item, String subscript, String superscript) {
		this.builder.append(item);
		if (subscript != null) {
			this.builder.append("_{" + subscript + "}");
		}
		if (superscript != null) {
			this.builder.append("^{" + superscript + "}");
		}
		return this;
	}
	
	public LatexBuilder appendNewLine() {
		this.builder.append("\\\\");
		return this;
	}
	
	public LatexBuilder appendBigSlip() {
		this.builder.append("\\bigskip");
		return this;
	}
	
	public LatexBuilder append(String s) {
		this.builder.append(s);
		return this;
	}
	
	public LatexBuilder appendTabularEnvBegin(int numberOfColumns) {
		this.builder.append("\\begin{tabular}{|l|");
		for (int i = 0; i < numberOfColumns; i++) {
			this.builder.append("|c||c|");
		}
		this.builder.append("}");
		return this;
	}
	
	public LatexBuilder appendHorLine() {
		this.builder.append("\\hline");
		return this;
	}
	
	public LatexBuilder appendTabularEnvEnd() {
		this.builder.append("\\end{tabular}");
		return this;
	}
	
	public StringBuilder getStringBuilder() {
		return builder;
	}	
	
}
